home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / Hash_InitTable.man < prev    next >
Encoding:
Text File  |  1989-02-13  |  3.9 KB  |  135 lines

  1.  
  2.  
  3.  
  4. Hash_InitTable        C Library Procedures         Hash_InitTable
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NNAAMMEE
  11.      Hash_InitTable - set up new hash table
  12.  
  13. SSYYNNOOPPSSIISS
  14.      ##iinncclluuddee <<hhaasshh..hh>>
  15.  
  16.      Hash_InitTable(_t_a_b_l_e_P_t_r, _n_u_m_B_u_c_k_e_t_s, _k_e_y_T_y_p_e)
  17.  
  18. AARRGGUUMMEENNTTSS
  19.      Hash_Table   *_t_a_b_l_e_P_t_r    (in)      Structure to use to hold
  20.                                          information  about  hash
  21.                                          table.  Caller must have
  22.                                          allocated    space    at
  23.                                          *tablePtr, but need  not
  24.                                          have   initialized  con-
  25.                                          tents.
  26.  
  27.      int          _n_u_m_B_u_c_k_e_t_s   (in)      How many buckets  should
  28.                                          be  in  table initially.
  29.                                          If <=  0,  a  reasonable
  30.                                          default  will be chosen.
  31.                                          In any case, the  number
  32.                                          of  buckets  will change
  33.                                          dynamically    as    the
  34.                                          number of entries in the
  35.                                          table grows.
  36.  
  37.      int          _k_e_y_T_y_p_e      (in)      What type of  keys  will
  38.                                          be   used   for   table:
  39.                                          HHAASSHH__SSTTRRIINNGG__KKEEYYSS,
  40.                                          HHAASSHH__OONNEE__WWOORRDD__KKEEYYSS,   or
  41.                                          integer >= 2.
  42.  
  43. _________________________________________________________________
  44.  
  45.  
  46. DDEESSCCRRIIPPTTIIOONN
  47.      HHaasshh__IInniittTTaabbllee initializes a Hash_Table structure  and  sets
  48.      up  bucket  storage  for  the  table, with no entries in the
  49.      table initially.  It must be called before any other  opera-
  50.      tions are performed on the hash table.
  51.  
  52.      The _k_e_y_T_y_p_e argument indicates what type  of  keys  will  be
  53.      used  in  the  table.   HASH_STRING_KEYS means that all keys
  54.      will be strings, and that the  _k_e_y  argument  to  procedures
  55.      like Hash_FindEntry will be passed in as a string:
  56.  
  57.  
  58.           Hash_Table table;
  59.           Hash_Entry *entryPtr;
  60.           char *key = "foobar";
  61.  
  62.  
  63.  
  64.  
  65. Sprite v.1.0       Printed:  February 13, 1989                  1
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. Hash_InitTable        C Library Procedures         Hash_InitTable
  73.  
  74.  
  75.  
  76.           Hash_InitTable(&table, 0, HASH_STRING_KEYS);
  77.           entryPtr = Hash_FindEntry(&table, key);
  78.  
  79.      If _k_e_y_T_y_p_e is HASH_ONE_WORD_KEYS, then keys will be one-word
  80.      (Address)  values;   _k_e_y arguments passed to procedures like
  81.      HHaasshh__FFiinnddEEnnttrryy may be integers or any other  values  of  the
  82.      same  size  as  addresses, passed by casting the value to an
  83.      Address:
  84.  
  85.  
  86.           Hash_Table table;
  87.           Hash_Entry *entryPtr;
  88.           int key = 24;
  89.  
  90.           Hash_InitTable(&table, 0, HASH_ONE_WORD_KEYS);
  91.           entryPtr = Hash_FindEntry(&table, (Address) key);
  92.  
  93.      Finally, if _k_e_y_T_y_p_e is an integer greater than 1, then  keys
  94.      are multi-word values containing _k_e_y_T_y_p_e words (not bytes!),
  95.      passed into procedures like HHaasshh__FFiinnddEEnnttrryy by address:
  96.  
  97.  
  98.           Hash_Table table;
  99.           Hash_Entry *entryPtr;
  100.           int key[6] = {1,2,3,4,5,6};
  101.  
  102.           Hash_InitTable(&table, 0, 6);
  103.           entryPtr = Hash_CreateEntry(tablePtr, (Address) key);
  104.  
  105.  
  106. KKEEYYWWOORRDDSS
  107.      hash table, initialization, key
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. Sprite v.1.0       Printed:  February 13, 1989                  2
  132.  
  133.  
  134.  
  135.